//
// Created by francklinson on 2021/10/23 AT 12:06.
//
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <functional>
#include <climits>
#include <string>
#include "../myTool.h"

//using namespace std;
struct Entity {
    int x, y;

    int *getPositions() {
        return &x;
    }
};

int main() {
    int a = 1;
    double b = *(double *) &a;
    // 这么做会导致b(8bytes)查到a（4bytes)后面的4位
    Entity e = {5, 8};
    int *position = (int *) &e;
    std::cout << position[0] << "," << position[1] << std::endl;

    int *px = e.getPositions();
    *(px+1) = 4;

    int y = *(int *) ((char *) &e + 4); // 直接取后4位
    std::cout << y << std::endl;

    return 0;
}

